package com.pcj.blog.interceptor;/**
 * @param
 * @author pcj
 * @date 2021/12/27 15:31
 * @return
 */


import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 *
 * @className LoginInterceptor
 * @author pengcj
 * @date 2021/12/27 15:31
 */

public class LoginInterceptor implements HandlerInterceptor {
    @Override
   public boolean preHandle(HttpServletRequest request,
                            HttpServletResponse response,
                            Object handle) throws Exception {
        if(request.getSession().getAttribute("user")==null){
            response.sendRedirect("/admin");
            return false;
        }
       return true;
   }
}
